package com.j180.aspect;

import com.j180.bean.StudentBean;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class ParmAdvice {

    @Pointcut("execution(* com.j180.dao.impl.*.*(..))")
    private void myPointCut(){

    }

    @Before("myPointCut()&&args(obj)")
    public void getMethodParm(JoinPoint joinPoint,Object obj){

        System.out.println("前置通知======>>>>>");

        if(obj instanceof StudentBean   ){
            StudentBean studentBean = (StudentBean) obj;
            System.out.println(studentBean.getName());
        }else{
            Integer id = (Integer) obj;

            System.out.println("整型："+obj);
        }

        //System.out.println(obj);
       /* Object[] objs= joinPoint.getArgs();
        for (Object obj : objs) {

            System.out.println("参数为"+obj);
        }*/

    }

    @AfterReturning(value = "myPointCut()",returning = "datas")
    public void  getresturnVal(Object datas){

        System.out.println("方法执行后的返回值为"+datas);
    }
}
